<template>
  <div>
    <template v-if="milkStationFlag == 0">
      <van-form>
        <van-field label="销售批次" readonly input-align="right"> </van-field>
        <van-field label="生鲜乳来源" readonly input-align="right"> </van-field>
        <van-field label-width="40%" readonly label="生鲜乳数量（kg）" input-align="right"> </van-field>
        <van-field label-width="40%" readonly label="经手人" input-align="right"> </van-field>
      </van-form>
    </template>
    <template v-if="milkStationFlag == 1">
      <van-form>
        <title-panel />
        <van-field label="销售批次" readonly input-align="right"> </van-field>
        <van-field label="生鲜乳收购站名称" label-width="40%" readonly input-align="right"> </van-field>
        <van-field label-width="40%" readonly label="收购站经手人" input-align="right"> </van-field>
        <van-field label-width="40%" readonly label="生鲜乳总数量（kg）" input-align="right"> </van-field>
        <van-field label-width="40%" readonly label="生鲜乳来源（家）" input-align="right"> </van-field>
        <title-panel title="生鲜乳来源信息" />
        <div>
        <div>
          <van-field label="鲜奶来源" readonly input-align="right" > </van-field>
          <van-field label="销售批次" readonly input-align="right"> </van-field>
          <van-field label-width="40%" readonly label="生鲜乳数量（kg）" input-align="right"> </van-field>
        </div>
        </div>
      </van-form>
    </template>
  </div>
</template>
<script>
import TitlePanel from '@/components/titlePanel'
import {
  Form,
  Field,
  Calendar,
  RadioGroup,
  Radio,
  Dialog,
  Toast,
  DatetimePicker,
  Picker,
  Button,
  Icon,
  Cell,
  Popup,
  Image
} from 'vant'
import dayjs from 'dayjs'
import { getValue, setValue, setObject } from '@/utils/auth'
import { postHandle, getHandle } from '@/api'
export default {
  components: {
    TitlePanel,
    [Form.name]: Form,
    [Field.name]: Field,
    [Calendar.name]: Calendar,
    [RadioGroup.name]: RadioGroup,
    [Radio.name]: Radio,
    [Picker.name]: Picker,
    [DatetimePicker.name]: DatetimePicker,
    [Button.name]: Button,
    [Icon.name]: Icon,
    [Popup.name]: Popup,
    [Toast.name]: Toast,
    [Cell.name]: Cell,
    [Dialog.Component.name]: Dialog.Component,
    [Image.name]: Image,
    [Dialog.name]: Dialog
  },
  data() {
    return {
      imgs: '',
      fileInfoList: [],
      contentObj: {},
      flag: true,
      milkStationFlag: getValue('milkStationFlag'),
      objGlobal: {
        id: '',
        loginUserId: '',
        tenantCode: '',
        productBatchId: '',
        token: ''
      }
    }
  },
  created() {
    this.$bridge.register('getData', (loginUserId, tenantCode, token, productBatchId, id, loginName, type) => {
      // 请加上自己的事件列表事件
      this.objGlobal.productBatchId = productBatchId || ''
      this.objGlobal.id = id || ''
      this.objGlobal.loginName = loginName || ''
      this.objGlobal.tenantCode = tenantCode || ''
      this.objGlobal.loginUserId = loginUserId || ''
      setValue('allToken', token)
      this.initialize()
    })
  },
  mounted() {},
  methods: {
    getContent() {},
    goCompile() {},
    initialize() {
      getHandle(
        `/ccyt/api/bzh/farmOperation/queryDetail/${this.objGlobal.id}?loginUserId=${this.objGlobal.loginUserId}&tenantCode=${this.objGlobal.tenantCode}`
      ).then(res => {
        this.contentObj = res.data
        this.imgs = res.data.operationImgs
        this.fileInfoList = res.data.operationImgs.split(',')
      })
    },
    beforeClose(action, done) {
      if (action === 'confirm') {
        setTimeout(() => {
          postHandle(
            `/ccyt/api/bzh/farmOperation/delete/${this.id}?loginUserId=${this.objGlobal.loginUserId}&tenantCode=${this.objGlobal.tenantCode}`,
            { id: this.id, loginUserId: 1, tenantCode: 1 }
          ).then(res => {
            if (res.status == '0') {
              this.$toast(res.msg)
              done()
              this.$bridge.call('base.closePage')
            } else {
              this.$toast(res.msg)
              done()
            }
          })
        }, 1000)
      } else {
        done()
      }
    },
    deleteContent() {
      Dialog.confirm({
        title: '提示',
        message: '确定要删除吗',
        beforeClose: this.beforeClose
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.van-cell {
  line-height: 30px;
  height: 60px;
}

.footerImg {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #37b5b5;
  > img {
    width: 22px;
    height: 22px;
  }
}
.shop .bottom {
  position: fixed;
  bottom: 0;
  height: 68px;
  width: 100%;
  box-sizing: border-box;
  background: #ffffff;
  padding: 8px 10px 8px 14px;
  box-shadow: 0px -2px 5px 0px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.bthStyle {
  width: 56px;
  height: 20px;
  border-radius: 10px;
  border: 1px solid #2871fe;
}
.active {
  background-color: #fff;
  color: #2871fe;
}
</style>
